<template>
  <div class="globalHeaderS">
    <div class="navContainer">
      <div class="logoTitle">知乎者也</div>
      <div class="rightBtn">
        <ul v-if="!navData.isLogin">
          <li class="primary">注册</li>
          <li @click="toLogin" class="primary">登录</li>
        </ul>
        <div  v-else>
          <dropDrow :info="navData">
            <dropDownItem>新建文章</dropDownItem>
            <dropDownItem>编辑资料</dropDownItem>
            <dropDownItem :disable="true">退出登录</dropDownItem>
          </dropDrow>
        </div>
      </div>
      
    </div>
  </div>
</template>

<script lang="ts">
import {defineComponent,PropType} from 'vue'
import {useRouter} from 'vue-router'
import dropDrow from '../dropDown/dropDown.vue'
import dropDownItem from '../dropDown/drowDownItem.vue'
export interface NavProps{
  isLogin:boolean;
  username?:string;
  id?:string;
}
export default defineComponent({
  name:'GlobalHeader',
  components:{
    dropDrow,
    dropDownItem
  },
  props:{
    navData:{
      type: Object as PropType<NavProps>,
      require:true
    }
  },
  setup(){
    const router = useRouter()
    const toLogin = ()=>{
      router.push('/login')
    }

    return {
      toLogin
    }
  }
})
</script>

<style lang="less" scoped>
.globalHeaderS{
  width: 100%;
  height: 70px;
  background-color: rgb(64,158,255);
  .navContainer{
    width: 85%;
    height: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    // align-items: center;
    .logoTitle{
      font-size: 20px;
      font-weight: bold;
      color: #fff;
    }
    .rightBtn{
      display: flex;
      align-items: center;
      >ul{
        display: flex;
        list-style: none;
        align-items: center;
        margin-bottom: 0;
        li{
          padding: 5px 15px;
          border: 1px solid #fff;
          margin: 0 10px;
          // background-color: #fff;
          color: #fff;
          border-radius: 5px;
          cursor: pointer;
        }
      }
    }
  }
}
</style>